home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-09-21 | 1.5 KB | 47 lines | [TEXT/GEOL] |
- Item 6179423 21-Sept-89 09:07
-
- From: LINS Lins, Chuck
-
- To: D1165 Esha, David C Hands,PRT
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: Re: IDType vs item number
-
- David,
-
- Another solution is to add a data structure mapping IDTypes to the appropriate
- item number. Suppose, for example, you have three radio buttons with ID Types
- 'Fred', 'Foo ', and 'Bar ' corresponding to radio buttons 1, 2, and 3,
- respectively. An abstract interface for a map abstraction could be as follows
- (reduced for the sake of this example):
-
- PROCEDURE Bind (theMap : Map; theDomain : IDType; theRange : INTEGER);
-
- FUNCTION BoundTo (theMap : Map; theDomain : IDType) : INTEGER { range };
-
- You would initialize the map with the statements:
-
- Bind(myMap, 'Fred', 1);
- Bind(myMap, 'Foo ', 2);
- Bind(myMap, 'Bar ', 3);
-
- The order of the above statements is not important.
-
- Now when you get an IDType and need to find out which item number it is you can
- simply make the call:
-
- selectedItem := BoundTo(myMap, selectedIdType);
-
- This presumes you have an abstract data type which you've previously
- instaniated. If you'll have only a singl map in your program you can dispense
- with theMap parameter.
-
- How you implement the map is up to you. There are several possible data
- structures, (e.g., hash tables) but given that the number of elements in the
- map will be small (i.e., < 20) a simple linear list or unordered array will do.
-
- Chuck Lins
- Apple Computer, Inc.
-
-